package gscrapper.dao;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class CSVHelper {
	public static boolean saveToFile(String filename, String content) {
		try {
			OutputStreamWriter out = new OutputStreamWriter(
					new FileOutputStream(String.format("%s.csv", filename)),
					"UTF-8");
			out.write(content);
			out.close();
			return true;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
	}

	public static String toCSV(String name) {
		return String.format("\"%s\"", name.replaceAll("\"", "\"\""));
	}
}
